﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using IniHelper;

namespace ProjectSecretaryFactory
{
    public partial class ProjectSecretaryDialog : Form
    {
        private IniContainer infoContainer;

        public ProjectSecretaryDialog(IniContainer container)
        {
            InitializeComponent();

            this.infoContainer = container;
        }

        private void ProjectSecretaryDialog_Load(object sender, EventArgs e)
        {
        }

        private void btnCancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void btnApply_Click(object sender, EventArgs e)
        {
            save();
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            save();
            this.Close();
        }

        private void save()
        {
            if ((tbCCSC.Text == "") || (tbPNSC.Text == "") || (tbSPNSC.Text == "") || (tbPN.Text == "") || (tbSPN.Text == ""))
            {
                MessageBox.Show("Lack of Information!");
                return;
            }

            //Add information
            infoContainer.overwriteIniValue("FrameInfo", "CCSC", tbCCSC.Text);
            infoContainer.overwriteIniValue("FrameInfo", "CCE", tbCCE.Text);
            infoContainer.overwriteIniValue("FrameInfo", "PNSC", tbPNSC.Text);
            infoContainer.overwriteIniValue("FrameInfo", "PNE", tbPNE.Text);
            infoContainer.overwriteIniValue("FrameInfo", "SPNSC", tbSPNSC.Text);
            infoContainer.overwriteIniValue("FrameInfo", "SPNE", tbSPNE.Text);
            infoContainer.overwriteIniValue("FrameInfo", "PN", tbPN.Text);
            infoContainer.overwriteIniValue("FrameInfo", "SPN", tbSPN.Text);
            infoContainer.overwriteIniValue("FrameInfo", "Principal", tbPrincipal1.Text + ";" + tbPrincipal2.Text);
            infoContainer.overwriteIniValue("FrameInfo", "Approve", tbApprove.Text);
            infoContainer.overwriteIniValue("FrameInfo", "Review", tbReview.Text);

            infoContainer.setName(tbPN.Text + "-" + tbSPN.Text);

            infoContainer.save();
        }
    }
}
